<template>
  <section class="box">
    <handle-info :form="form" :callback="getData" :type='2' v-if="form.id"></handle-info>
  </section>
</template>
<script>
  import {getStudentDetail, studentUpdate} from 'api/school/student/index'
  import handleInfo from 'components/student/handleInfo'
  import common from 'src/util/common'
  export default {
    data () {
      return {
        form: {}, // form数据
        id: common.params('id') // 学生id
      }
    },
    created () {
      getStudentDetail({id: this.id}).then(v => {
        this.form = v.data
      })
    },
    components: {
      handleInfo
    },
    methods: {
      getData (data) {
        studentUpdate(data).then(v => {
          if (v.errcode === '0') {
            this.$router.push({name: 'studentManage'})
          } else {
            this.$message({
              showClose: true,
              message: v.errmsg,
              type: 'error',
              duration: 2000
            })
          }
        })
      }
    }
  }
</script>